package com.yjs.ppjokedemo.ui.detail;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.bumptech.glide.Glide;
import com.shuyu.gsyvideoplayer.video.GSYSampleADVideoPlayer;
import com.yjs.ppjokedemo.R;
/**
 * 视频详情页面
 * 并未实现视频可以滑动同时展示出评论区
 * */
@Route(path = "/app/SofaVideoDetailActivity")
public class SofaVideoDetailActivity extends AppCompatActivity {

    @Autowired
    Bundle dataBean;

    private GSYSampleADVideoPlayer detailGsy;
    private ImageView ivVideoTou;
    private TextView tvVideoName;
    private ImageView ivVideoLike;
    private TextView tvVideoLike;
    private ImageView ivVideoCollected;
    private TextView tvVideoCollected;
    private ImageView ivVideoShare;
    private TextView tvVideoShare;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sofa_video_detail);
        initView();
    }

    private void initView() {
        ARouter.getInstance().inject(this);
        detailGsy = (GSYSampleADVideoPlayer) findViewById(R.id.detail_gsy);
        ivVideoTou = (ImageView) findViewById(R.id.iv_video_tou);
        tvVideoName = (TextView) findViewById(R.id.tv_video_name);
        ivVideoLike = (ImageView) findViewById(R.id.iv_video_like);
        tvVideoLike = (TextView) findViewById(R.id.tv_video_like);
        ivVideoCollected = (ImageView) findViewById(R.id.iv_video_collected);
        tvVideoCollected = (TextView) findViewById(R.id.tv_video_collected);
        ivVideoShare = (ImageView) findViewById(R.id.iv_video_share);
        tvVideoShare = (TextView) findViewById(R.id.tv_video_share);

        //TODO 视频实现无缝续播
        detailGsy.setUp(dataBean.getString("videoUrl"),false,"");
        detailGsy.getFullscreenButton().setVisibility(View.GONE);
        detailGsy.getBackButton().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        //TODO 视频播放器进度条取消失败
        Glide.with(this)
                .load(dataBean.getString("ivtou"))
                .circleCrop()
                .into(ivVideoTou);

        tvVideoName.setText(dataBean.getString("name"));

    }
}